package com.hison.courseselectionsystem.controller;

import com.hison.courseselectionsystem.domain.Teacher;
import com.hison.courseselectionsystem.dto.LoginFormById;
import com.hison.courseselectionsystem.dto.UpdatePwd;
import com.hison.courseselectionsystem.service.TeacherService;
import com.hison.courseselectionsystem.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName: TeacherController
 * @Descripiton: 教师控制类
 * @Author: 小郑
 * @Date： 2023/11/17 12:31
 * @Version：1.8
 **/
@Api(value = "教师接口", description = "教师接口，提供教师的登录，查询个人信息，修改个人信息，修改密码，查询教授学生信息，管理学生等")
@RequestMapping("/teacher")
@RestController
public class TeacherController {

    @Resource
    private TeacherService teacherService;

    /**
     * 教师注册
     *
     * @param teacher
     * @return {@link Result}
     */
    @ApiOperation(value = "教师注册接口", notes = "供用户注册，默认密码123456", produces = "application/json")
    @PostMapping("/register")
    public Result register(@RequestBody Teacher teacher) {
        return teacherService.register(teacher);
    }

    /**
     * 用户登录接口   通过账号密码登录
     *
     * @param loginFormByStuId
     * @return {@link Result}
     */
    @ApiOperation(value = "教师登录接口", notes = "用户通过教师账号和密码登录", produces = "application/json")
    @PostMapping("/loginbyid")
    public Result login(@RequestBody LoginFormById loginFormByStuId) {
        return teacherService.login(loginFormByStuId);
    }

    @ApiOperation(value = "获取教师个人信息", notes = "获取个人详细信息", produces = "application/json")
    @GetMapping("/me")
    public Result getInfo(@RequestParam("teacherId") String teacherId) {
        return teacherService.getInfo(teacherId);
    }


    @ApiOperation(value = "修改密码", produces = "application/json")
    @PostMapping("/updatePwd")
    public Result updatePwd(@RequestBody UpdatePwd updatePwd) {
        return teacherService.update(updatePwd);
    }


}